<template>
  <div class="team-discount">
    <!-- 【营销】团长优惠 -->
    <team-captain-discount :info="marketingData" :prePayParams="prePayParams" :queryParams="queryParams"
      @dataChange="dataChange" />
  </div>
</template>

<script>
import Mimir from "@xiaoe/mimir";

export default {
  props: {
    marketingData: {
      type: Object,
      default: () => ({})
    },
    baseInfo: {
      type: Object,
      default: () => ({})
    },
    count: {
      type: Number,
      default: 1
    }
  },
  components: {
    TeamCaptainDiscount: () => Mimir({ section: 'market' }).get("team-captain-discount"),
  },
  data() {
    return {}
  },
  computed: {
    queryParams() {
      let link = window.location.search
      let objParams = new URLSearchParams(link)
      let queryParams = {}
      for (let [key, value] of objParams) {
        queryParams[key] = value
      }
      return queryParams
    },
    prePayParams() {
      let data = {
        activity_id: this.marketingData?.activity_id,
        activity_type: this.marketingData?.activity_type,
        count: this.count,
        team_buy_id: this.marketingData?.team_buy_id,
        team_buy_user_type: this.marketingData?.team_buy_user_type,
        team_buy_task_id: this.marketingData?.task_id,
        team_num: this.baseInfo?.step
      }
      return data;
    }
  },
  methods: {
    dataChange(data) {
      const result = {
        name: 'teamBuy',
        preParams: data?.payParams,
        triggerPrePay: false
      }
      this.$emit('changeFormData', result);
    }
  }
};
</script>

<style lang="scss" scoped>
.team-discount {
  padding: 0 .32rem;
  background: #fff;
}
</style>
